import myAxios from "../../plugins/myAxios";
import { Toast } from "vant";
import { timeDate } from "../../util/dateTimeFormat.js";
// 队伍页条件分页查询
export const teamPageQueryUser = async (param) => { 
    const [teamListData, total] = await myAxios
        .get("/team", {
            params: {
                ...param
            },
        })
        .then((res) => {
            if (res.data.code == 1) {
                console.log("/team/recommend success", res.data.data);
                // Toast.success("查询队伍成功");
                if (res.data.data.records) {
                    res.data.data.records.forEach((team) => {
                        if (team.expireTime) {
                            // 将时间戳转化为日期
                            team.expireTime = timeDate(new Date(team.expireTime));
                        }
                        if (team.createTime) {
                            team.createTime = timeDate(new Date(team.createTime));
                        }
                        if (team.updateTime) {
                            team.updateTime = timeDate(new Date(team.updateTime));
                        }
                    });
                }
                return [res.data.data.records, res.data.data.total];
            } else {
                console.error("/team error", res.data.message);
                Toast.fail("查询队伍失败");
                return [null, null];
            }
        });
    // 返回查询到的用户列表 和 总记录条数
    return [teamListData, total];
};
